package com.jiazhong.basic.pack0308.coll;

public class Student {
    private Integer id;
    private String name;
    private Character gender; // sex
    private Integer age;
    private String address;

    public Student() {
    }

    public Student(Integer id, String name, Character gender, Integer age, String address) {
        this.id = id;
        this.name = name;
        this.gender = gender;
        this.age = age;
        this.address = address;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", gender=" + gender +
                ", age=" + age +
                ", address='" + address + '\'' +
                '}';
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Character getGender() {
        return gender;
    }

    public void setGender(Character gender) {
        this.gender = gender;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    // 改写了Object类的方法（重写）

    @Override
    public boolean equals(Object obj) {
        System.out.println("开始比较" + this + "和" + obj);
        // 需求:只要id相同就是同一个对象
        // 我的ID
        int myId = this.getId();
        // 他的ID
        Student it = (Student) obj;
        int itId = it.getId();
        return myId == itId;
    }
}
